package cn.xd.core.service;

import cn.xd.common.dto.PageQuery;
import cn.xd.core.converter.Converter;
import cn.xd.core.ddd.entity.BasicEntity;
import cn.xd.core.ddd.value.IdValue;
import cn.xd.core.entity.BasicDBEntity;
import cn.xd.core.response.CollectResult;
import cn.xd.core.response.IntegerResult;
import cn.xd.core.response.ObjectResult;
import cn.xd.core.response.OptionalObjectResult;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.jeffreyning.mybatisplus.service.IMppService;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

/**
 * @author mirzaLin
 * @data 2023/11/14
 * @description 基础mpService
 **/
public interface BasicMpService<T extends BasicDBEntity> extends IMppService<T> {
    <R extends BasicEntity> OptionalObjectResult<T> saveResult(R entity, Converter<R, T> converter);

    OptionalObjectResult<T> saveResult(T entity);

    IntegerResult saveAllBatchResult(Collection<T> batchList);

    <R extends BasicEntity> IntegerResult updateResult(R entity, Converter<R, T> converter);

    <R extends BasicEntity> IntegerResult updateNotSelectiveResult(R entity, Converter<R, T> converter);

    IntegerResult updateResult(T entity);

    IntegerResult updateNotSelectiveResult(T entity);

    ObjectResult<T> getResult(Serializable id);

    <R> ObjectResult<R> getResult(Serializable id, Converter<R, T> converter);

    <R> ObjectResult<R> getResult(IdValue id, Converter<R, T> converter);

    ObjectResult<T> getResult(IdValue id);

    ObjectResult<T> getOneForLimitOneResult(Wrapper<T> wrapper);

    <R> ObjectResult<R> getOneForLimitOneResult(Wrapper<T> wrapper, Converter<R, T> converter);

    Page<T> getPage(Wrapper<T> wrapper, PageQuery page);

    <R> Page<R> getPage(Wrapper<T> wrapper, Converter<R, T> converter, PageQuery page);

    <R> CollectResult<R> getList(Wrapper<T> wrapper, Converter<R, T> converter);
}
